/**
  ******************************************************************************
  * @file    main.c
  * @author  AE Team
  * @version 1.0.3
  * @date    2024-05-28
  * @brief   演示读取芯片的所有数字签名信息
  *          通过UART打印出读取的信息
  *
  * @note    硬件平台：SYM32L010_StartKit_V1.0
  *          接线说明：短接J13
  *
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2024 SIYIMicro.
  * All rights reserved.</center></h2>
  *
  *
  ******************************************************************************
  */


/******************************************************************************/
/* Include files                                                              */
/******************************************************************************/
#include "main.h"
#include "sym32l010_hal_sysctrl.h"
#include "sym32l010_hal_systick.h"
#include "sym32l010_hal_gpio.h"
#include "sym32l010_hal_sign.h"
#include "sym32l010_Startkit_board.h"


/******************************************************************************/
/* Local pre-processor symbols/macros ('#define')                             */
/******************************************************************************/

/******************************************************************************/
/* Global variable definitions (declared in header file with 'extern')        */
/******************************************************************************/
uint8_t  LongUid[10];
uint8_t  ShortUid[6];
uint8_t  PartNo[22];
uint32_t FlashSize;
uint32_t RamSize;
uint8_t  PinCount;

/******************************************************************************/
/* Local type definitions ('typedef')                                         */
/******************************************************************************/

/******************************************************************************/
/* Local function prototypes ('static')                                       */
/******************************************************************************/

/******************************************************************************/
/* Local variable definitions ('static')                                      */
/******************************************************************************/

/******************************************************************************/
/* Local pre-processor symbols/macros ('#define')                             */
/******************************************************************************/

/******************************************************************************/
/* Function implementation - global ('extern') and local ('static')           */
/******************************************************************************/


/*******************************************************************************
 ** \brief  Main function of project
 **
 ** \return uint32_t return value, if needed
 **
 **
 ******************************************************************************/
int32_t main(void)
{
    // 初始化系统时钟
    HAL_SysCtrl_ConfigWaitCycle(48000000);
    HAL_SysCtrl_HSI_SetDiv(HSIOSC_TO_HSI48MHZ);

    // 初始化SysTick
    HAL_InitTick(48000000);

    // 板载 UART 初始化
    Bsp_Uart_Init(48000000, 115200);

    HAL_SIGN_ReadLongUid(LongUid);
    HAL_SIGN_ReadShortUid(ShortUid);
    HAL_SIGN_ReadPartNo(PartNo);

    FlashSize = HAL_SIGN_ReadFlashSize();
    RamSize   = HAL_SIGN_ReadRamSize();
    PinCount  = HAL_SIGN_ReadPinCount();
    while (1)
    {
        printf("LongUid   : 0x");
        for (uint8_t i = 0; i < sizeof(LongUid); i++)
        {
            printf("%02X", LongUid[i]);
        }
        printf("\r\n");

        printf("ShortUid  : 0x");
        for (uint8_t i = 0; i < sizeof(ShortUid); i++)
        {
            printf("%02X", ShortUid[i]);
        }
        printf("\r\n");

        printf("PartNo    : %s\r\n", PartNo);
        printf("FlashSize : %d Byte\r\n", FlashSize);
        printf("RamSize   : %d Byte\r\n", RamSize);
        printf("PinCount  : %d Pin\r\n", PinCount);

        HAL_Delay(200);
    }
}


/*******************************************************************************
 ** EOF (not truncated)
 ******************************************************************************/
#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
    /* USER CODE BEGIN */
    /* User can add his own implementation to report the file name and line number,
       tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
    /* USER CODE END */
}
#endif /* USE_FULL_ASSERT */


/************************ (C) COPYRIGHT SIYIMicro *****END OF FILE*************/
